﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using DslModeling=global::Microsoft.VisualStudio.Modeling;
using DslDiagrams=global::Microsoft.VisualStudio.Modeling.Diagrams;
using DslValidation=global::Microsoft.VisualStudio.Modeling.Validation;

namespace Salamanca.Saml
{

    partial class ActivityState:
        INamedElement
    {
        partial class NamePropertyHandler
        {
            protected override void OnValueChanging(ActivityState element, string oldValue, string newValue)
            {
                if (!element.Store.InUndoRedoOrRollback)
                    if (string.IsNullOrEmpty(newValue))
                        throw new ArgumentOutOfRangeException("Name", Resources.SR.NameCannotBeNull);

                base.OnValueChanging(element, oldValue, newValue);
            }
        }

        /// <summary>Ensures that names will be valid C# identifiers.</summary>
        [DslValidation.ValidationMethod(DslValidation.ValidationCategories.Menu | DslValidation.ValidationCategories.Open | DslValidation.ValidationCategories.Save)]
        private void ValidateName(DslValidation.ValidationContext context)
        {
            NamedElement.ValidateName(context, this);
        }

    }
}
